package com.yangjun.controller.businessAnalysis.flowAnalysis;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.yangjun.entity.businessAnalysis.SemConversionEntity;
import com.yangjun.service.bussiness.SemConversionService;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


/**
 * 
 * @ClassName ChannelConversionController
 * @Description Sem渠道转化
 * @author Administrator
 * @Date 2017年1月12日 下午2:26:13
 * @version 1.0.0
 */
@RestController
@RequestMapping(value="/api/businessAnalysis/semConversion/",method=RequestMethod.GET)
public class SemConversionController {
	private static Logger logger = Logger.getLogger(SemConversionController.class);  
	@Autowired
	private SemConversionService semConversionService;
	
	@ApiOperation(value="获取该页面平台标识",notes="SEM")
	@ResponseBody
	@RequestMapping(value="querySiteId")
	public Map<String,String> querySiteId(){
		return semConversionService.querySiteId();
	}
	
	@ApiOperation(value="获取Sem当天流量销售实时数据",notes="按日期,平台筛选")
	@ResponseBody
	@RequestMapping(value="querySiteDayFlow")
	public Map<String,SemConversionEntity> querySiteDayFlow(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="contrastDate", value ="对比日期") @RequestParam(value = "contrastDate",required = false)String contrastDate){
		return semConversionService.querySiteDayFlow(siteid,contrastDate);
	}
	
	
	@ApiOperation(value="来访次数，访客数，新访客，跳出率分小时折线图图",notes="今日与对比日比较")
	@ResponseBody
	@RequestMapping(value="querySiteHourFlow")
	public Map<String,Object> querySiteHourFlow(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="currentDate", value ="当前日期") @RequestParam(value = "currentDate",required = false)String currentDate,
			@ApiParam(required = true, name ="contrastDate", value ="对比日期") @RequestParam(value = "contrastDate",required = false)String contrastDate){
		
		return semConversionService.querySiteHourFlow(siteid,currentDate,contrastDate);
	}
	@ApiOperation(value="根据点击行为查询对应行为销售分小时折线图",notes="今日与对比日比较")
	@ResponseBody
	@RequestMapping(value="querySiteHourActionNetamt")
	public Map<String,Object> querySiteHourActionNetamt(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="action", value ="点击事件") @RequestParam(value = "action",required = false)String action,
			@ApiParam(required = true, name ="currentDate", value ="当前日期") @RequestParam(value = "currentDate",required = false)String currentDate,
			@ApiParam(required = true, name ="contrastDate", value ="对比日期") @RequestParam(value = "contrastDate",required = false)String contrastDate){
		return semConversionService.querySiteHourActionNetamt(siteid,action,currentDate,contrastDate);
	}
	@ApiOperation(value="来访次数，访客数，新访客，跳出率分小时分渠道折线图",notes="今日与对比日比较")
	@ResponseBody
	@RequestMapping(value="querySiteChannelHourFlow")
	public Map<String,Object> querySiteChannelHourFlow(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="channel", value ="渠道") @RequestParam(value = "channel",required = false)String channel,
			@ApiParam(required = true, name ="currentDate", value ="当前日期") @RequestParam(value = "currentDate",required = false)String currentDate,
			@ApiParam(required = true, name ="contrastDate", value ="对比日期") @RequestParam(value = "contrastDate",required = false)String contrastDate){
		return semConversionService.querySiteChannelHourFlow(siteid,channel,currentDate,contrastDate);
	}

	@ApiOperation(value="查询渠道流量表格",notes="根据平台日期筛选")
	@ResponseBody
	@RequestMapping(value="queryChannelTable")
	public Map<String,Object> queryChannelTable(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="date", value ="日期") @RequestParam(value = "date",required = false)String date,
			@ApiParam(required = true, name ="dimension", value ="需要排序的字段") @RequestParam(value = "dimension",required = false)String dimension,
			@ApiParam(required = true, name ="orderBy", value ="排序方式") @RequestParam(value = "orderBy",required = false)String orderBy){
		return semConversionService.queryChannelTable(siteid,date,dimension,orderBy);
	}
	@ApiOperation(value="查询来源关键词流量表格",notes="根据平台日期筛选")
	@ResponseBody
	@RequestMapping(value="querySourceKeywordTable")
	public List<String[]> querySourceKeywordTable(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="date", value ="日期") @RequestParam(value = "date",required = false)String date,
			@ApiParam(required = true, name ="channel", value ="渠道") @RequestParam(value = "channel",required = false)String channel,
			@ApiParam(required = true, name ="dimension", value ="需要排序的字段") @RequestParam(value = "dimension",required = false)String dimension,
			@ApiParam(required = true, name ="orderBy", value ="排序方式") @RequestParam(value = "orderBy",required = false)String orderBy){
		return semConversionService.querySourceKeywordTable(siteid,date,channel,dimension,orderBy);
	}
	@ApiOperation(value="查询渠道来源关键词流量表格",notes="根据平台日期关键词筛选")
	@ResponseBody
	@RequestMapping(value="queryChannelSourceKeywordTable")
	public List<String[]> queryChannelSourceKeywordTable(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="date", value ="日期") @RequestParam(value = "date",required = false)String date,
			@ApiParam(required = true, name ="channel", value ="渠道") @RequestParam(value = "channel",required = false)String channel,
			@ApiParam(required = true, name ="sourceKeyword", value ="来源关键词") @RequestParam(value = "sourceKeyword",required = false)String sourceKeyword){
		return semConversionService.queryChannelSourceKeywordTable(siteid,date,channel,sourceKeyword);
	}
	@ApiOperation(value="来访次数，访客数，新访客，跳出率分小时分渠道分来源关键词折线图",notes="今日与对比日比较")
	@ResponseBody
	@RequestMapping(value="querySiteChannelSourceKeywordHourFlow")
	public Map<String,Object> querySiteChannelSourceKeywordHourFlow(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="channel", value ="渠道") @RequestParam(value = "channel",required = false)String channel,
			@ApiParam(required = true, name ="sourceKeyword", value ="来源关键词") @RequestParam(value = "sourceKeyword",required = false)String sourceKeyword,
			@ApiParam(required = true, name ="currentDate", value ="当前日期") @RequestParam(value = "currentDate",required = true)String currentDate,
			@ApiParam(required = true, name ="contrastDate", value ="对比日期") @RequestParam(value = "contrastDate",required = true)String contrastDate){
		return semConversionService.querySiteChannelSourceKeywordHourFlow(siteid,channel,sourceKeyword,currentDate,contrastDate);
	}
	
	@ApiOperation(value="来访次数，访客数，订单数，销售额饼图",notes="日期筛选")
	@ResponseBody
	@RequestMapping(value="queryHourAndProvincePie")
	public Map<String,Object> queryHourAndProvincePie(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="date", value ="日期") @RequestParam(value = "date",required = false)String date){
		return semConversionService.queryHourAndProvincePie(siteid,date);
	}
	
	@ApiOperation(value="渠道热销商品",notes="日期，渠道，平台筛选")
	@ResponseBody
	@RequestMapping(value="queryHotSalesWares")
	public List<String[]> queryHotSalesWares(
			@ApiParam(required = true, name ="siteid", value ="平台") @RequestParam(value = "siteid",required = false)String siteid,
			@ApiParam(required = true, name ="date", value ="日期") @RequestParam(value = "date",required = false)String date,
			@ApiParam(required = true, name ="channel", value ="渠道") @RequestParam(value = "channel",required = false)String channel,
			@ApiParam(required = true, name ="dimension", value ="需要排序的字段") @RequestParam(value = "dimension",required = false)String dimension,
			@ApiParam(required = true, name ="orderBy", value ="排序方式") @RequestParam(value = "orderBy",required = false)String orderBy){
		return semConversionService.queryHotSalesWares(siteid, date, channel,dimension,orderBy);
	}
}
